#!/usr/bin/python3
import sys

try:
    t = int(input())
    if t < 1 or t > 100:
        sys.exit(0)
    for x in range(t):
        a = 0
        b = 0
        c = 0
        n = int(input())
        if n < 1 or n > 1000:
            sys.exit(0)
        for y in range(n):
            inStr = input()
            if inStr != "":
                ls = inStr.split()
                if int(ls[2]) >= 60:
                    a = a + 1
                    b = b + 1
                    c = c + 1
                elif int(ls[1]) >= 60:
                    a = a + 1
                    b = b + 1
                elif int(ls[0]) >= 60:
                    a = a + 1
            else:
                break

        print("Case #%d: %d %d %d" % (x + 1, a, b, c))

except ValueError:
    pass
except EOFError:
    pass
except MemoryError:
    pass
